package com.dangdang.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.StringUtils;

/**
 * 类别表
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-1-21
 */

public class Category implements Serializable {

	private static final long serialVersionUID = 1L;

	public String getCatValue() {
		return this.catValue;
	}

	private Integer id;

	/** 类别名称 */
	private String name;

	/** 父类别ID */
	private Integer parentId;

	/** 排序级别 */
	private String catValue;

	/** 该类商品所拥有的产品 */
	private Set<Product> products = new HashSet<Product>(0);

	public Set<Product> getProducts() {
		return this.products;
	}

	public void setProducts(Set<Product> products) {
		this.products = products;
	}

	/** default constructor */
	public Category() {
	}

	public int getLevel() {
		return StringUtils.countMatches(catValue, "|");
	}

	public void setCatValue(String catValue) {
		this.catValue = catValue;
	}

	/** minimal constructor */
	public Category(String name) {
		this.name = name;
	}

	/** full constructor */
	public Category(String name, Integer parentId) {
		this.name = name;
		this.parentId = parentId;
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getParentId() {
		return this.parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

}